package ast;

/** 
 * Constantes utilizadas para la generacion de codigo en Processing 
 */

public class ConstCode {
	
	/**
     * Constantes de generacion de codigo
     */
	
	// id entradas
	public static final int ID_FOTOREST	= 7;
	public static final int ID_BOTON	= 8;
	public static final int ID_POTENC	= 9;
	
	// operaciones matematicas
	public static final String SUMA 	 	= "+";
	public static final String RESTA 	 	= "-";
	public static final String DIV	 	 	= "/";
	public static final String MULTI 	 	= "*";
	public static final String MODULO 	 	= "%";
	public static final String ASIG 	 	= "=";
	public static final String ASIG_SUMA	= "+=";
	public static final String ASIG_RESTA 	= "-=";
	
	// definiciones y constantes
	public static final String MAX 				= "9";
	public static final String CERO 		 	= "0";
	public static final String HIGH 			= "HIGH";
	public static final String LOW 				= "LOW";
	public static final String VAR 				= "var_";
	public static final String FLUJO 			= "flujo";
	public static final String DELAY_FUNCTION 	= "delay( ";
	public static final String DIGITAL_WRITE 	= "digitalWrite( ";
	public static final String WRITE_NUM 		= "writeNum( ";
	public static final String FUNCTION 		= "function_";
	public static final String FACTOR_TIME 		= "1000";
	public static final String PINMODE		 	= "pinMode ( ";
	public static final String PINMODE_FIN		= ", OUTPUT ); \n ";
	public static final String INI_FLUJO		= "int flujo = 0; \n";
	
	// string de union y enlace
	public static final String PARAM_FUNCTION 	= "()";
	public static final String OPEN_FUNCTION 	= "( ";
	public static final String CIERRE_FUNCTION 	= " )";
	public static final String FIN_LINE 		= "; \n";
	public static final String COMA 			= ",";
	public static final String IF_EXP		 	= "if( ";
	public static final String END_IF_EXP	 	= " ){ \n";
	public static final String END_CORCHET	 	= " } \n";
	public static final String OPEN_CORCHET	 	= "{  \n";
	public static final String INT	 			= "int ";
	public static final String ELSE			 	= "} else { \n";
	public static final String ELSE_IF			= " else if { \n";
	
	
	// comparaciones
	public static final String MENOR 		= "<";
	public static final String MENOR_IGUAL 	= "<=";
	public static final String MAYOR	 	= ">";
	public static final String MAYOR_IGUAL 	= ">=";
	public static final String IGUAL 		= "==";
	public static final String DIFERENTE 	= "!=";
	
	// funciones
	public static final String WRITE_NUM_FUNCTION 	=
		"                                // A  B  C  D  pines        \n" +
		"byte seven_seg_digits[10][8] = { { 0, 0, 0, 0 },  // = 0    \n" +
		"                                 { 0, 0, 0, 1 },  // = 1    \n" +
        "                                 { 0, 0, 1, 0 },  // = 2    \n" +
        "                                 { 0, 0, 1, 1 },  // = 3    \n" +
        "                                 { 0, 1, 0, 0 },  // = 4    \n" +
        "                                 { 0, 1, 0, 1 },  // = 5    \n" +
        "                                 { 0, 1, 1, 0 },  // = 6    \n" +
        "                                 { 0, 1, 1, 1 },  // = 7    \n" +
        "                                 { 1, 0, 0, 0 },  // = 8    \n" +
        "                                 { 1, 0, 0, 1 }   // = 9    \n" +
        "                       };                                   \n" +
        "                                                            \n" +
		"int  writeNum( byte pin, byte digit ) {                     \n" +
		"	for (byte cntPin = 0; cntPin < 4; ++cntPin) {            \n" +
		"		digitalWrite(pin, seven_seg_digits[digit][cntPin]);  \n" +
		"		++pin;                                               \n" +
		"	}                                                        \n" +
		"	return digit;                                            \n" +
		"}                                                           \n";
	
	public static final String SETUP_FUNCTION 	= 
		"void setup(){                                              \n" +
		"	// 7 segmentos                                          \n" +
		"	pinMode (2, OUTPUT);                                    \n" +
		"	pinMode (3, OUTPUT);                                    \n" +
		"	pinMode (4, OUTPUT);                                    \n" +
		"	pinMode (5, OUTPUT);                                    \n" +
		"   // leds                                                 \n";
	
	public static final String LOOP 		= 
		"void loop() {                                              \n" +
		"	// escribir en potenciometro                            \n" +
		"	flujo = writeNum( 2, analogRead( 1)/103 );              \n" +
		"	// iniciar programa                                     \n" +
		"	if( digitalRead(7) == HIGH ){                           \n" +
		"	    function_0();                                       \n" +
		"   }                                                       \n" +
		"}                                                          \n";
	
	
		  
		  
		  
		       
		    
	
}

	